package com.niit.ai.dl.dltrain.dao;

import java.util.List;

import com.niit.ai.dl.dltrain.dao.model.Model;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ModelDao {
    @Select("SELECT * FROM model limit #{start},#{size}")
    List<Model> queryList(@Param("start") Integer start, @Param("size") Integer size);

    @Select("SELECT * FROM model where model_type = #{modelType}")
    List<Model> queryListByType(@Param("modelType") Integer modelType);

    @Select("SELECT * FROM model where id=#{id}")
    Model getById(@Param("id") Integer id);

    @Select("SELECT count(*) FROM model")
    Integer total();

    @Insert("insert into model (name, model_type, file_path, comment) values (#{name}, #{modelType}, #{filePath}, #{comment})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer insert(Model model);

    @Delete("delete from model where id=#{id}")
    Integer delete(@Param("id") Integer id);

    @Update("update model set name=#{name}, model_type=#{modelType}, file_path=#{filePath}, comment=#{comment} where id=#{id}")
    Integer update(Model model);
}
